# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=cloud-hypervisor
pkgver=37.0
pkgrel=0
pkgdesc="Virtual machine monitor for modern cloud workloads"
url="https://www.cloudhypervisor.org/"
# Only x86_64 and aarch64 are officially supported
arch="x86_64 aarch64"
license="Apache-2.0 AND BSD-3-Clause"
makedepends="cargo libcap-utils cargo-auditable"
source="https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/v$pkgver/cloud-hypervisor-v$pkgver.tar.xz"
builddir="$srcdir/$pkgname-v$pkgver"
# tests require CAP_NET_ADMIN capability
# setcap cap_net_admin
options="!check setcap"

prepare() {
	default_prepare
	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen
}

package() {
	install -Dm755 -t "$pkgdir"/usr/bin/ \
		target/release/cloud-hypervisor \
		target/release/ch-remote

	# Needs NET_ADMIN capabilities to set TAP interfaces up on the host
	setcap cap_net_admin=+ep "$pkgdir"/usr/bin/cloud-hypervisor
}

sha512sums="
45a37cef72991bb75aa7ea9aeb523225d17ef7c285b96bb08e06aa8d4ba980c166697dab1cc58a1307092d7298c52a751d740eb438e28b0fa021ca6c3bfac4e2  cloud-hypervisor-v37.0.tar.xz
"
